/***
  * 用户详细列表
  * 展示用户详细
  * @version 1.0.0
  * @author yangyibao 
  */
function userInfoDiv(json){
	//用户详细信息DIV
	var userInfoDiv ='<div class="tabbable tabbable-custom boxless">'+'<ul class="nav nav-tabs">'
    +'<li  class="active"><a href="#tab_1" data-toggle="tab">基本信息</a></li>'
    +'<li><a href="#tab_1_2" data-toggle="tab">扩展信息</a></li>'+'</ul><br>'
    +'<div class="tab-content">'
	   +'<div class="tab-pane active" id="tab_1">'
    +'<table class="table table-striped table-hover table-bordered dt-responsive" style="margin-top:-20px;">'+
	   		'<tbody>'+
	   			'<tr>'+
	   				'<td rowspan="5" style="width:20%"><img src="'+json.userProfile.userPhotoUrl+'"></img></td>'+
	   				'<td style="width:15%" class="bold font-blue-hoki">账号 </td>'+
	   				'<td>'+json.userNo+'</td>'+
	   				'<td  style="width:20%" class="bold font-blue-hoki">姓名</td>'+
	   				'<td>'+null2Str(json.userName)+'</td>'+
	   			'</tr>'+
	   			'<tr>'+
	   				'<td style="width:15%" class="bold font-blue-hoki">性别</td>'+
	   				'<td>'+sex2Str(json.userProfile.userGender)+'</td>'+
	   				'<td style="width:15%" class="bold font-blue-hoki">电子邮箱</td>'+
	   				'<td>'+null2Str(json.userEmail)+'</td>'+
             '</tr>'+
             '<tr>'+
             	'<td class="bold font-blue-hoki">创建时间</td>'+
             	'<td>'+json.createDate+'</td>'+
             	'<td class="bold font-blue-hoki" style="maxlength:11;">联系电话</td>'+
         		'<td>'+null2Str(json.userTel)+'</td>'+
             '</tr>'+
	   		'</tbody>'+
	   	'</table>'+'</div>'+
	    '<div class="tab-pane" id="tab_1_2">'
	    +'<table class="table table-striped table-hover table-bordered dt-responsive" style="margin-top:-20px;">'+
	 	  	'<tbody>'+
	 	  		'<tr>'+
                '<td style="width:10%" class="bold font-blue-hoki">最近登录IP</td>'+
                '<td style="width:30%">'+null2Str(json.lastLoginIp)+'</td>'+
                '</tr>'+
                '<tr>'+ 
                '<td style="width:10%" class="bold font-blue-hoki">最近登录时间</td>'+
                '<td  style="width:30%">'+null2Str(json.latestOpDate)+'</td>'+
            '</tr>'+
        '</tbody>'+
     '</table>'+'</div>'+
	'</div>'+'</div>';
return userInfoDiv;
}

/**
 * 角色变更信息页
 */
function roleInfoDiv(id,role){
	$.post(IMS_PATH+"/user/roleList",{userId:id,role:role},function(data){
		//----
//		var roleBodyDiv = '<div class="controls"><label class="radio line">';
//		var flg = '';
//		for(var i=0;i<data.rolesList.length;i++){
//			if (id == 1){
//				flg = (data.rolesList[i].roleId==data.role)?'checked':'';
//				roleBodyDiv = roleBodyDiv+'<div class="radio"><span><input type="radio" id="radio'+data.rolesList[i].roleId+'" name="role" value='+data.rolesList[i].roleId+' class="md-radiobtn" '+flg+'></span></div><font><font>'+data.rolesList[i].roleName+'</font></font></label>';
//			}else{
//				if(data.rolesList[i].roleName != "管理用户"){
//					flg = (data.rolesList[i].roleId==data.role)?'checked':'';
//					roleBodyDiv = roleBodyDiv+'<div class="radio"><span><input type="radio" id="radio'+data.rolesList[i].roleId+'" name="role" value='+data.rolesList[i].roleId+' class="md-radiobtn" '+flg+'></span></div><font><font>'+data.rolesList[i].roleName+'</font></font></label>';
//				}
//			}
//		}
//		roleBodyDiv = roleBodyDiv+'</div><input type="hidden" id="userRoleId" value="'+id+'" /></div>';
//		$("#roleInfoDiv .modal-body").html(roleBodyDiv);
//		$("#roleInfoDiv").modal("show");
		//=====
		var roleBodyDiv = '<div class="md-radio-inline">';
		var flg = '';
		for(var i=0;i<data.rolesList.length;i++){
			if (id == 1){
				flg = (data.rolesList[i].roleId==data.role)?'checked':'';
				roleBodyDiv = roleBodyDiv+'<div class="md-radio" style="line-height:40px"><input style="margin:0px 6px 2px" type="radio" id="radio'+data.rolesList[i].roleId+'" name="role" value='+data.rolesList[i].roleId+' class="md-radiobtn" '+flg+'>'+'<label style="display:inline" for="radio'+data.rolesList[i].roleId+'"><span></span><span class="check"></span><span class="box"></span>'+data.rolesList[i].roleName+'</label></div>';
			}else{
				if(data.rolesList[i].roleName != "管理用户"){
					flg = (data.rolesList[i].roleId==data.role)?'checked':'';
					roleBodyDiv = roleBodyDiv+'<div class="md-radio" style="line-height:40px"><input style="margin:0px 6px 2px" type="radio" id="radio'+data.rolesList[i].roleId+'" name="role" value='+data.rolesList[i].roleId+' class="md-radiobtn" '+flg+'>'+'<label style="display:inline" for="radio'+data.rolesList[i].roleId+'"><span></span><span class="check"></span><span class="box"></span>'+data.rolesList[i].roleName+'</label></div>';
				}
			}
		}
		roleBodyDiv = roleBodyDiv+'<input type="hidden" id="userRoleId" value="'+id+'" /></div>';
		$("#roleInfoDiv .modal-body").html(roleBodyDiv);
		$("#roleInfoDiv").modal("show");
	});
}

/**
 * 性别转码
 * @param sex
 * @returns {String}
 */
function sex2Str(sex){
	if(sex == null || typeof(sex) == "undefined"||sex =='')
		return '<font class="font-red">尚未设置</font>';
	return (sex=='1')?'男':'女';
}

/**
 * null/undefined 字符转化
 * @param str
 * @returns
 */
function null2Str(str){
	if(str == null || typeof(str) == "undefined"||str =='')
		return '<font class="font-red">尚未设置</font>';
	return str;
}

/**
 * 增加用户基本信息
 */
function userSaveDiv(departmentStr,roleIdStr){
	var userSaveDiv = '<div class="form"><div class="form">'+
    					'<form class="form-horizontal" id="userBaseForm" method="post">'+
		    					'<div class="control-group">'+
									'<label class="control-label">角色设置:<span class="required">*</span></label>'+
									'<div class="controls">'+
										'<select class="span3 m-wrap selectpicker" name="roleDefaultId" data-live-search="true" id="roleDefaultId" >'+roleIdStr+'</select>'+
									'</div>'+
								'</div>'+
	    						'<div class="control-group">'+
									'<label class="control-label">用户账号:<span class="required">*</span></label>'+
									'<div class="controls">'+
										'<input type="text" id="userNo" name="userNo" data-required="userNo" class="span3 m-wrap" placeholder="请填写用户账号(小写字母和数字组合)，不能超过14个字符！">'+
									'</div>'+
								'</div>'+
								'<div class="control-group">'+
									'<label class="control-label">用户姓名:<span class="required">*</span></label>'+
									'<div class="controls">'+
										'<input type="text" id="userName" name="userName" data-required="userName" class="span3 m-wrap" placeholder="请填写用户名称，不能超过8个字符！">'+
									'</div>'+
								'</div>'+
								'<div class="control-group">'+
									'<label class="control-label">组织机构:<span class="required">*</span></label>'+
									'<div class="controls">'+
										'<select class="span3 m-wrap selectpicker" name="departId" data-live-search="true" id="departId" >'+departmentStr+'</select>'+
									'</div>'+
								'</div>'+
								'<div class="control-group">'+
									'<label class="control-label">联系电话:<span class="required">*</span></label>'+
									'<div class="controls">'+
										'<input type="text" id="userTel" name="userTel" data-required="userTel" class="span3 m-wrap" placeholder="请填写联系电话名称，不能超过11个字符！">'+
									'</div>'+
								'</div>'+
								'<div class="control-group">'+
									'<label class="control-label">电子邮箱:<span class="required">*</span></label>'+
									'<div class="controls">'+
										'<input type="text" id="userEmail" name="userEmail" data-required="userEmail" class="span3 m-wrap" placeholder="请填写电子邮箱名称，不能超过20个字符！">'+
									'</div>'+
								'</div>'+
    					'</form>'+
    				'</div></div>';
	return userSaveDiv;
}
